<?php
	include "configure.php";	

	$Date = date("Y-m-d");
	
	$Filename = $Date.".csv";
	
	header("Content-type:application/vnd.ms-excel");
	header("Content-Disposition:filename=".$Filename);
	$query = "select * from comptype";
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result))
		$type[$row['uid']] = $row['name'];
	$query = "select * from components";
	$result = mysql_query($query);
	echo "元件名,元件类型,值,数量,保管位置（保管人）,描述\n";
	while ($row=mysql_fetch_array($result))
		echo "$row[name]," . $type[$row['type']] . ",$row[value],$row[num],$row[position],$row[description]\n";
	
?>
